File Upload/Download

Description

The File Upload/Download control is an invisible control that is used with the File Upload and File Download Action Javascript actions to add uploading and downloading files to and from the Alpha Anywhere Appliaction Server in a UX component that uses data binding.

Discussion

In order to add an event handler that performs a file upload action, you must add a special [File Upload/Download] control to the UX component.

The [File Upload/Download] control is in the Other Controls section of the Toolbox.

images/fileuploaddownload.jpg

Once you have added the [File Upload/Download] control, you can then use Action Javascript to define a File Upload Action.

The [File Upload/Download] control can be data bound (just like any other control).

However, it is not required that the [File Upload/Download] control be data bound. If the control is not data bound, then then it is your responsibility to decide what to do with the uploaded binary data when the UX Component is submitted.

If the [File Upload/Download] control is data bound, it can be bound to either a character field or a binary field. When the UX Component is submitted, the uploaded data will be saved into the corresponding bound field (assuming you have added a Save Record Server-side event handler to the AfterValidate event).

If the [File Upload/Download] control is bound to a binary field, the binary contents of the uploaded file will be saved in the bound field.

If the [File Upload/Download] control is bound to a character field, the filename of the uploaded file will be stored in the character field, and the uploaded file itself will be stored in the folder that you specified when you defined the File Upload Action. (Actually, the transformed filename, as specified by the 'Stored filename transformation expression' will be stored in the bound field).

In the case where the [File Upload/Download] control is not data bound, your AfterValidate event handler can retrieve the binary data that was uploaded as follows (assuming that the Id of the [File Upload/Download] control is 'FILEUPLOAD_1'):

dim blobKey as c

'Every [File Upload/Download] control has an associated control with

'a '_A5FILEUPLOAD' name.

'After the file has been uploaded, it is stored in temporary session storage

'The 'key' for the data in session storage is stored in this hidden field.

blobKey = e.dataSubmitted.FILEUPLOAD_1__A5FILEUPLOAD
blobKey = word(blobKey,1,":")

dim blobUploaded as b
context.session.GetDataFromFile(blobUploaded,blobKey)
context.session.DeleteSessionFile(blobKey)

'You now have the uploaded file data in a variable called 'blobUploaded'

'Your event handler can process this data.

File Upload/Download Actions

Action Javascript
Description
File Upload

Uploads a file to the Appliaction Server. Requires the [File Upload/Download] control.

File Download

Download a file to the client. The [File Upload/Download] control can be used with this action and data binding to supply the file to download.

Videos

'File Upload' Action in Action Javascript

This video shows how you can configure the UX component to upload a file to the Alpha Anywhere server and then store the filename of the uploaded file in a character field in the table to which the UX component is data bound.

2015-02-15

Tutorial - Uploading Files and Images to a Data Bound UX Component

When you upload a file or an image to a data bound UX component, the assumption is that you want to store the uploaded image or file in the record to which the UX component is bound. You can either store the binary data that was uploaded in a field in the record, or you can save the binary data that was uploaded into a file on the server and then store the filename of the file in a character field in the record.

In this video we show how image upload and file upload to a data bound UX component can be done. Images and files are uploaded to both binary and character fields in the record.

Download Component

2014-10-02

The zip file also contains the MySQL SQL script to create the table that the UX component is based on.

See Also